package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoMountType;
import com.muyu.danmo.service.IDanmoMountTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 装裱类型Controller
 * 
 * @author yangle
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/danmoMountType")
public class DanmoMountTypeController extends BaseController
{
    @Autowired
    private IDanmoMountTypeService danmoMountTypeService;

    /**
     * 查询装裱类型列表
     */
//    @RequiresPermissions("system:danmoMountType:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoMountType>> list(DanmoMountType danmoMountType)
    {
        startPage();
        List<DanmoMountType> list = danmoMountTypeService.selectDanmoMountTypeList(danmoMountType);
        return getDataTable(list);
    }

    /**
     * 导出装裱类型列表
     */
//    @RequiresPermissions("system:danmoMountType:export")
    @Log(title = "装裱类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoMountType danmoMountType)
    {
        List<DanmoMountType> list = danmoMountTypeService.selectDanmoMountTypeList(danmoMountType);
        ExcelUtil<DanmoMountType> util = new ExcelUtil<DanmoMountType>(DanmoMountType.class);
        util.exportExcel(response, list, "装裱类型数据");
    }

    /**
     * 获取装裱类型详细信息
     */
//    @RequiresPermissions("system:danmoMountType:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoMountTypeService.selectDanmoMountTypeById(id));
    }

    /**
     * 新增装裱类型
     */
//    @RequiresPermissions("system:danmoMountType:add")
    @Log(title = "装裱类型", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoMountType danmoMountType)
    {
        return toAjax(danmoMountTypeService.insertDanmoMountType(danmoMountType));
    }

    /**
     * 修改装裱类型
     */
//    @RequiresPermissions("system:danmoMountType:edit")
    @Log(title = "装裱类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoMountType danmoMountType)
    {
        return toAjax(danmoMountTypeService.updateDanmoMountType(danmoMountType));
    }

    /**
     * 删除装裱类型
     */
//    @RequiresPermissions("system:danmoMountType:remove")
    @Log(title = "装裱类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoMountTypeService.deleteDanmoMountTypeByIds(ids));
    }



}
